<template>
	<div class="image-box" :class="className">
		<div v-if="props.data.data && props.data.data.length > 0">
			<a v-for="(item, index) in props.data.data" :key="index" :href="item.link">
				<img :src="item.url" v-if="item.url" />
				<div class="image-null" v-else>
					<el-icon><Picture /></el-icon>
				</div>
			</a>
		</div>
		<div v-else>
			<div class="image-null">
				<el-icon><Picture /></el-icon>
			</div>
		</div>
	</div>
</template>

<script setup lang="ts">
const props = defineProps({
	// 列表内容
	data: {
		type: Object,
		default: () => {},
	},
	className: {
		type: Object,
		default: () => {},
	},
});
</script>

<style lang="scss" scoped>
.image-box {
	font-size: 0;
	margin-left: 5px;
	margin-right: 5px;
	margin-top: 10px;
	img {
		width: 100%;
		max-width: 100%;
	}
	.image-null {
		background: #ffffff;
		border-radius: 20px;

		width: 100%;
		height: 100px;
		font-size: 50px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #c1c1c1;
	}
	a {
		display: block;
	}
	&.two {
		display: flex;
		flex-wrap: wrap;
		box-sizing: content-box;
		a {
			width: 50%;
			box-sizing: border-box;
			position: relative;
			overflow: hidden;
			display: block;
			padding-bottom: 50%;
			background: #e4e4e4;
			img {
				position: absolute;
			}
		}
	}
	&.three {
		height: 100px;
		overflow-y: auto;
		white-space: nowrap;
		box-sizing: content-box;
		a {
			width: 100px;
			height: 100px;
			margin: 0 4px;
			display: inline-block;
			vertical-align: bottom;
			background: #e4e4e4;
		}
	}
}
</style>
